import Home from '@/views/Home.vue';
import login from '@/views/login.vue'
const routes = [
  {
    path: '/login',
    name: 'Login',
    component: login
  },
  {
    path:'/eventBusParent',
    name:'EventBusParent',
    component:()=>import('@/views/eventBusParent.vue')
  },
  {
    path:'/renderPage',
    name:'RenderPage',
    component:()=>import('@/views/renderPage.vue')
  },
 {
    path:'/renderPageJsx',
    name:'RenderPageJsx',
    component:()=>import('@/views/renderPageJsx.vue')
  },
  {
    path:'/renderPageSlot',
    name:'RenderPageSlot',
    component:()=>import('@/views/renderPageSlot.vue')
  },
  {
    path: '/',
    name: 'Home',
    alias: '/home_page',//设置别名
    component: Home,
    meta:{
      title:'首页'
    },
    props: route => ({
      name: route.query.name
    }),
    beforeEnter:(to,from,next)=>{
      console.log('beforeEnter',to.name);
      next()
    }
  },
  {
    path: '/about/:name',
    name: 'About',
    component: () => import(/* webpackChunkName: "about" */ '@/views/About.vue'),
    beforeEnter:(to,from,next)=>{
      console.log('进来home');
      next()
    }
  },
  {
    path: '/argument/:name',
    name: 'Argument',
    component: () => import(/* webpackChunkName: "agru" */'@/views/argument.vue'),
    props: true
  },
  {
    path: '/parent',
    name: 'Parent',
    props: {
      name: 'parentJack'
    },
    component: () => import(/* webpackChunkName: "parent" */'@/views/parent.vue'),
    children: [
      {
        path: 'child',
        name: 'Child',
        component: () => import(/* webpackChunkName: "child" */'@/views/child.vue'),
      }
    ]
  },
  {
    path: '/named_view',
    name: 'NamedView',
    components: {
      default: () => import('@/views/child.vue'),
      email: () => import('@/views/email.vue'),
      tel: () => import('@/views/tel.vue')
    }
  },
  {
    path: '/main',
    // redirect:{
    //   name:'Home'
    // }
    // redirect:to=>{
    //   console.log('to',to);
    //   return {
    //     name:'Home'
    //   }
    // }
    redirect: to => '/'
  },
  {
    path: '*',
    name: '404',
    component: () => import(/* webpackChunkName: "404" */'@/views/404.vue'),
  }
];

export default routes;
